package pub.wkq.thread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.IntStream;

/**
 * @author 王开琦
 */
public class SingleThreadException {
    public static void main(String[] args) {
        ExecutorService exec = Executors.newSingleThreadExecutor();
        IntStream.range(0, 10).mapToObj(NapTask::new).forEach(exec::execute);
        System.out.println("All task submitted");
        exec.shutdown();
//        while (!exec.isTerminated()) {
//            System.out.println(Thread.currentThread().getName() + ": await termination");
//            new Nap(0.1);
//        }
    }
}
